/*!
 @header AboutViewController.m
 @author 周益
 @version 1.0.0 2013/02/21 Creation
 Copyright (c) 2013年 mypocketbaby. All rights reserved.
 */

#import "AboutViewController.h"
#import "Helper.h"
#import "Config.h"
#import "RTLabel.h"

//  -业务逻辑细节说明-
//
//  @abstract       AboutViewController功能较为简单，并无业务逻辑，显示农户宝的版本、版权等其它信息
//

//  @discussion

//  @notes          


//  -类修改日志-
//  修改人   修改时间   针对版本   修改描述

@interface AboutViewController ()

@end

@implementation AboutViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
    UIButton *backButton = [Helper buttonWithStyle:ButtonStyleNavigationReturn];
    [backButton addTarget:self action:@selector(backButtonEvent:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    self.view.backgroundColor = _SYS_COLOR_BACKGROUND;
    
    UIImageView *bgImageView = [[UIImageView alloc] init];
    
    if (iPhone5) {
        
        bgImageView.frame = CGRectMake(0.0f, 0.0f, 320.0f, 1007.0f/2.0f);
        bgImageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"com_img_009-568h@2x" ofType:@"png"]];
    }else{
        
        bgImageView.frame = CGRectMake(0.0f, 0.0f, 320.0f, 831.0f/2.0f);
        bgImageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"com_img_008@2x" ofType:@"png"]];
    }
    [self.view addSubview:bgImageView];
    
    //版本描述
    UILabel *versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 185.0f, 320.0f, 15.0f)];
    if (iPhone5) {
        versionLabel.frame = CGRectMake(0.0f, 220.0f, 320.0f, 15.0f);
    }
    versionLabel.textAlignment = UITextAlignmentCenter;
    versionLabel.font = _SYS_FONT_003;
    versionLabel.text = _L(@"title_50");
    
    versionLabel.backgroundColor = [UIColor clearColor];
    [self.view addSubview:versionLabel];
    
    //手机类别描述
    UILabel *categoryLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, versionLabel.frame.size.height + versionLabel.frame.origin.y, 315.0f, 15.0f)];
    categoryLabel.textAlignment = UITextAlignmentCenter;
    categoryLabel.textColor = _SYS_COLOR_002;
    categoryLabel.font = _SYS_FONT_001;
    categoryLabel.text = _L(@"title_51");
    categoryLabel.backgroundColor = [UIColor clearColor];
    [self.view addSubview:categoryLabel];
    
//    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 390.0f) style:UITableViewStyleGrouped];
//    _tableView.scrollEnabled = NO;
//    _tableView.delegate = self;
//    _tableView.dataSource = self;
//    _tableView.backgroundView = nil;
//    _tableView.backgroundColor = _SYS_COLOR_BACKGROUND;
//    [self.view addSubview:_tableView];
//    
//    //allrights
//    RTLabel *rightsLabel = [[RTLabel alloc] initWithFrame:CGRectMake(0.0f, _tableView.frame.origin.y + _tableView.frame.size.height, 320.0f, 480.0f-20.0f-45.0f-390.0f)];
//    rightsLabel.text = @"<font size=13 color='#71771c'>POWERED BY BORN ALLRIGHTS RESERVED</font>";
//    rightsLabel.textAlignment = RTTextAlignmentCenter;
//    rightsLabel.backgroundColor = [UIColor clearColor];
//    [self.view addSubview:rightsLabel];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    // Configure the cell...
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    if (indexPath.section == 0) {
        
        //logo
        UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(cell.contentView.center.x - 61.5f/2.0f - 10.0f, cell.contentView.center.y, 61.5f, 62.0f)];
        logoImageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"more_icon_002@2x" ofType:@"png"]];
        [cell.contentView addSubview:logoImageView];
        
        //版本描述
        UILabel *versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, logoImageView.frame.size.height + logoImageView.frame.origin.y + 10.0f, 300.0f, 15.0f)];
        versionLabel.textAlignment = UITextAlignmentCenter;
        versionLabel.textColor = _SYS_COLOR_002;
        versionLabel.font = _SYS_FONT_003;
        versionLabel.text = _L(@"title_50");
        
        versionLabel.backgroundColor = [UIColor clearColor];
        [cell.contentView addSubview:versionLabel];
        
        //手机类别描述
        UILabel *categoryLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, versionLabel.frame.size.height + versionLabel.frame.origin.y + 5.0f, 300.0f, 15.0f)];
        categoryLabel.textAlignment = UITextAlignmentCenter;
        categoryLabel.textColor = _SYS_COLOR_002;
        categoryLabel.font = _SYS_FONT_003;
        categoryLabel.text = _L(@"title_51");
        categoryLabel.backgroundColor = [UIColor clearColor];
        [cell.contentView addSubview:categoryLabel];
        
    }else if(indexPath.section == 1){
        
        //微博地址
        RTLabel *weiboLabel = [[RTLabel alloc] initWithFrame:CGRectMake(10.0f, 10.0f, 300.0f, 20.0f)];
        weiboLabel.text = _L(@"tpl_07");
        weiboLabel.font = _SYS_FONT_003;
        [cell.contentView addSubview:weiboLabel];
        
        //email
        RTLabel *emailLabel = [[RTLabel alloc] initWithFrame:CGRectMake(10.0f, weiboLabel.frame.size.height + weiboLabel.frame.origin.y + 5.0f, 300.0f, 20.0f)];
        emailLabel.text = _L(@"tpl_08");
        emailLabel.font = _SYS_FONT_003;
        [cell.contentView addSubview:emailLabel];
        
        
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 150.0f;
    }
    return 100.0f;
}


#pragma mark - 自定义事件

/*!
 @abstract 返回按钮事件
 */
- (void)backButtonEvent:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
